package Logicamente;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;
import javax.swing.border.EmptyBorder;
import java.awt.Toolkit;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class VentanaJugar extends javax.swing.JFrame {
	private JButton jButton_crear;
	private JButton jButton_unirse;
	private JButton jButton1;
	private JPanelConFondo contentPane;

	{
		//Set Look & Feel
		try {
			javax.swing.UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
		} catch(Exception e) {
			e.printStackTrace();
		}
	}


	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				VentanaJugar inst = new VentanaJugar(null);
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public VentanaJugar(Usuario u) {
		super();
		setTitle("Logicamente");
		setIconImage(Toolkit.getDefaultToolkit().getImage(VentanaJugar.class.getResource("/Imagenes/L.png")));
		contentPane = new JPanelConFondo("/Imagenes/fondo.jpg");
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);
		initGUI(u);
	}
	
	private void initGUI(final Usuario u) {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			{
				jButton_crear = new JButton();
				getContentPane().add(jButton_crear);
				jButton_crear.setText("Crear Partida");
				jButton_crear.setBounds(148, 54, 151, 43);
				jButton_crear.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						jButton_crearActionPerformed(u);
					}
				});
			}
			{
				jButton_unirse = new JButton();
				getContentPane().add(jButton_unirse);
				jButton_unirse.setText("Unirse a Partida");
				jButton_unirse.setBounds(148, 144, 149, 46);
				jButton_unirse.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						jButton_unirseActionPerformed(evt,u);
					}
				});
			}
			{
				jButton1 = new JButton();
				contentPane.add(jButton1);
				jButton1.setText("Sugerir preguntas");
				jButton1.setBounds(148, 242, 151, 37);
			}
			pack();
			this.setSize(454, 353);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}

	protected void jButton_crearActionPerformed(Usuario u) {
		VentanaCrearPartidaA v = new VentanaCrearPartidaA(u);
		v.setLocationRelativeTo(null);
		v.setVisible(true);			
		this.setVisible(false);
		this.hide();
	}

	protected void jButton_unirseActionPerformed(ActionEvent evt,Usuario u) {
		VentanaUnirse v = new VentanaUnirse(u);
		v.setLocationRelativeTo(null);
		v.setVisible(true);			
		this.setVisible(false);
		this.hide();
	}

}
